<template>
  <base-layout>
    <template #searchPanel>
      <search-panel
        v-slot="{ form }"
        :addPer="'111'"
        :selectPer="'111'"
        addTitle="新增盘点单"
        @insert="add"
        @search="search"
        :showSearchButton="true"
        :showAddButton="true"
      >
        <el-select
          style="width: 200px"
          clearable
          v-model="form.storeId"
          placeholder="所属门店"
        >
          <el-option
            v-for="item in stores"
            :key="item.id"
            :value="item.id"
            :label="item.storeName"
          />
        </el-select>
        <el-select
          clearable
          style="width: 200px"
          v-model="form.type"
          placeholder="状态"
        >
          <el-option
            v-for="item in getDict(['置换类型'])['置换类型']"
            :key="item.index"
            :value="item.value"
            :label="item.text"
          />
        </el-select>
        <el-input
          v-model="form.client"
          clearable
          placeholder="盘点单号"
          style="width: 200px"
        />
      </search-panel>
    </template>
    <template #contentPanel>
      <data-table
        :value="tableData"
        :total-count="totalCount"
        :has-action="true"
        :table-column-attributes="tableColumnAttributes"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :width="160"
      >
        <template #action="{ row }">
          <i
            v-if="row.status != '盘点完成'"
            class="el-icon-edit"
            title="编辑"
            style="margin-left: 15px; cursor: pointer"

            @click="updateUser(row)"
          ></i>
          <i
            class="el-icon-delete"
            title="删除"
            style="color: red; margin-left: 20px; cursor: pointer"

            @click="handleDataDelete(row)"
          ></i>
        </template>
      </data-table>
    </template>
  </base-layout>
</template>
<script>
import baseMixin from '@/mixins/base'
import { getDict } from '@/utils/index'
import { mapGetters } from 'vuex'
export default {
  mixins: [
    baseMixin({
      idName: 'id',
      findData: [],
      dataName: ['content', 'totalRecords'],
      format(res) {
        return res.map((data) => {
          data.statusName = data.status == true ? '启用' : '禁用'
          return data
        })
      }

    })
  ],
  computed: {
    ...mapGetters(['stores', 'storesCalue'])
  },
  data() {
    return {
      getDict: getDict,
      form: {
        phone: '', // 电话
        status: '', // 状态
        storeId: '', // 门店id
        userName: '' // 用户名
      },
      tableColumnAttributes: [
        {
          name: '盘点门店',
          value: 'storeName',
          type: 'text'
        },
        {
          name: '盘点单号',
          value: 'code',
          type: 'text'
        },
        {
          name: '单据日期',
          value: 'account',
          type: 'text'
        },
        {
          name: '盘点仓库',
          value: 'roleName',
          type: 'text'
        },
        {
          name: '盘点数量',
          value: 'phone',
          type: 'text'
        },
        {
          name: '总金额',
          value: 'createTime',
          type: 'text'
        },
        {
          name: '盘点负责人',
          value: 'loginTime',
          type: 'text'
        },
        {
          name: '状态',
          value: 'phone',
          type: 'text'
        },
        {
          name: '盘点结果',
          value: 'createTime',
          type: 'text'
        },
        {
          name: '备注',
          value: 'loginTime',
          type: 'text'
        }
      ],
      dict: {}
    }
  },
  methods: {
    // 编辑员工信息
    updateUser(row) {
      // const { id } = row
      // this.$router.push({
      //   path: '/personnel/updataEmployee',
      //   query: {
      //     userId: id
      //   }
      // })
    },
    // 查询
    search() {
      this.searchOptions = this.form
      this.currentPage = 1
      this.setTableData()
    },
    add() {

    }
  },
  mounted() {

  }
}
</script>
